home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / language / harvest.cpt / Harvest C / CWarningsDialog.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-16  |  6.3 KB  |  240 lines

  1. /*
  2.     Harvest C
  3.     Copyright 1992 Eric W. Sink.  All rights reserved.
  4.     
  5.     This file is part of Harvest C.
  6.     
  7.     Harvest C is free software; you can redistribute it and/or modify
  8.     it under the terms of the GNU Generic Public License as published by
  9.     the Free Software Foundation; either version 2, or (at your option)
  10.     any later version.
  11.     
  12.     Harvest C is distributed in the hope that it will be useful,
  13.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.     GNU General Public License for more details.
  16.     
  17.     You should have received a copy of the GNU General Public License
  18.     along with Harvest C; see the file COPYING.  If not, write to
  19.     the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  20.     
  21.     Harvest C is not in any way a product of the Free Software Foundation.
  22.     Harvest C is not GNU software.
  23.     Harvest C is not public domain.
  24.  
  25.     This file may have other copyrights which are applicable as well.
  26.  
  27. */
  28.  
  29. /******************************************************************************
  30.  CWarningsDialog.c
  31.  
  32.         
  33.     SUPERCLASS = CDLOGDirector
  34.     
  35.     Copyright ⌐ 1991 Symantec Corporation. All rights reserved.
  36.     
  37.  
  38.  ******************************************************************************/
  39.  
  40. #include "CWarningsDialog.h"
  41. #include "CWarningsPane.h"
  42. #include "CWarningsArray.h"
  43. #include "CScrollPane.h"
  44. #include "CDialogText.h"
  45. #include "CDialog.h"
  46. #include "CPaneBorder.h"
  47. #include "CApplication.h"
  48. #include "CHarvestApp.h"
  49. #include "CHarvestDoc.h"
  50. #include "CHarvestOptions.h"
  51. #include "CDataFile.h"
  52. #include "CSourceFile.h"
  53. #include "Commands.h"
  54. #include "HarvestCommands.h"
  55. #include "AppleEvents.h"
  56. #include "Aliases.h"
  57. #include "stdarg.h"
  58. #include "tclAE.h"
  59.  
  60. #define    kDemoDlgID            1050
  61. #define openFileTCLID        5000
  62.  
  63. enum        /* window item numbers    */
  64. {
  65.     kListScrollPaneItem = 1
  66. };
  67.  
  68. extern CHarvestApp    *gApplication;
  69. extern CHarvestDoc    *gProject;
  70. extern tSystem gSystem;
  71. extern CSourceFile *gCurSourceFile;
  72. extern CWarningsDialog *gErrs;
  73.  
  74. /******************************************************************************
  75.  IWarningsDialog
  76. ******************************************************************************/
  77.  
  78. #define maxStringLen 255
  79.  
  80. void CWarningsDialog::IWarningsDialog( CHarvestOptions *theOpts,CWarningsArray *theWarnings)
  81. {
  82.     CScrollPane    *scrollPane;
  83.     CPaneBorder *listBorder;
  84.     Rect    margin;
  85.     Cell    aCell;
  86.     
  87.  
  88.     CDLOGDirector::IDLOGDirector( kDemoDlgID, gApplication);
  89.     
  90.     itsOptions = theOpts;
  91.  
  92.     scrollPane = (CScrollPane*) itsWindow->FindViewByID( kListScrollPaneItem);
  93.     warningOn = (CCheckBox *) itsWindow->FindViewByID( 2);
  94.     allOn = (CRadioControl *) itsWindow->FindViewByID( 4);
  95.     allOff = (CRadioControl *) itsWindow->FindViewByID( 5);
  96.     indiv = (CRadioControl *) itsWindow->FindViewByID( 6);
  97.     radioPane = (CRadioGroupPane *) itsWindow->FindViewByID( 3);
  98.  
  99.     if (scrollPane)
  100.     {                
  101.         itsWarningsPane = new( CWarningsPane);
  102.         itsWarningsPane->IWarningsPane( scrollPane, itsWindow, 0, 0, 0, 0,
  103.             sizELASTIC, sizELASTIC);
  104.         itsWarningsPane->FitToEnclosure( TRUE, TRUE);
  105.         itsWarningsPane->SetDrawActiveBorder( TRUE);
  106.         itsWarningsPane->SetDblClickCmd(cmdToggleWarning);
  107.         
  108.         itsWarningsPane->SetID( 10);
  109.  
  110.         listBorder = new( CPaneBorder);
  111.         listBorder->IPaneBorder( kBorderFrame);
  112.         itsWarningsPane->SetBorder( listBorder);
  113.                 
  114.         itsWarningsPane->SetSelectionFlags( selOnlyOne);
  115.         
  116.         scrollPane->InstallPanorama( itsWarningsPane);
  117.         
  118.         itsWarnings = theWarnings;
  119.         itsWarningsPane->SetArray( itsWarnings, FALSE);
  120.         
  121.         SetCell( aCell, 0, 0);
  122.         itsWarningsPane->SelectCell( aCell, FALSE, FALSE);
  123.     }
  124.     
  125.     warningOn->SetClickCmd(cmdToggleWarning);
  126.     allOn->SetClickCmd(cmdAllWarningsOn);
  127.     allOff->SetClickCmd(cmdAllWarningsOff);
  128.     indiv->SetClickCmd(cmdIndividuallySet);
  129.  
  130.     radioPane->SetStationID(6);
  131.     
  132.     SetupItems();
  133. }    /* CWarningsDialog::IWarningsDialog */
  134.  
  135. /******************************************************************************
  136.  DoCommand
  137. ******************************************************************************/
  138.  
  139. void CWarningsDialog::DoCommand( long aCmd)
  140. {
  141.     Cell    selectedCell;
  142.     Str255    string;
  143.     Boolean haveSelection;
  144.     struct Warning w;
  145.     
  146.     SetCell( selectedCell, 0, 0);
  147.     haveSelection = itsWarningsPane->GetSelect( TRUE, &selectedCell);
  148.     
  149.     switch (aCmd)
  150.     {
  151.         case cmdToggleWarning:
  152.             itsWarnings->GetItem((Ptr) &w, selectedCell.v+1);
  153.             itsOptions->warnings[w.num] = !itsOptions->warnings[w.num];
  154.             if (itsOptions->warnings[w.num]) {
  155.                 warningOn->SetValue(BUTTON_ON);
  156.             }
  157.             else {
  158.                 warningOn->SetValue(BUTTON_OFF);
  159.             }
  160.             itsWarningsPane->RefreshCell(selectedCell);
  161.             break;
  162.         case cmdAllWarningsOn:
  163.             itsOptions->allWarnings = TRUE;
  164.             itsOptions->noWarnings = FALSE;
  165.             break;
  166.         case cmdAllWarningsOff:
  167.             itsOptions->allWarnings = FALSE;
  168.             itsOptions->noWarnings = TRUE;
  169.             break;
  170.         case cmdIndividuallySet:
  171.             itsOptions->allWarnings = FALSE;
  172.             itsOptions->noWarnings = FALSE;
  173.             break;
  174.         default: 
  175.                 inherited::DoCommand( aCmd);
  176.                 break;
  177.     }
  178.                 
  179. }    /* CWarningsDialog::DoCommand */
  180.  
  181. /******************************************************************************
  182.  SetupItems
  183. ******************************************************************************/
  184.  
  185. void CWarningsDialog::SetupItems( void)
  186. {
  187.     Cell    selectedCell;
  188.     Boolean haveSelection;
  189.     CDialog    *dialog;
  190.     struct Warning w;
  191.  
  192.     /* determine if any cells are now selected    */
  193.     
  194.     SetCell( selectedCell, 0, 0);
  195.     haveSelection = itsWarningsPane->GetSelect( TRUE, &selectedCell);
  196.     
  197.     dialog = (CDialog*) itsWindow;
  198.     
  199.     if (haveSelection) {
  200.         itsWarnings->GetItem((Ptr) &w, selectedCell.v+1);
  201.         if (itsOptions->warnings[w.num]) {
  202.             warningOn->SetValue(BUTTON_ON);
  203.         }
  204.         else {
  205.             warningOn->SetValue(BUTTON_OFF);
  206.         }
  207.     }
  208.     else {
  209.     }
  210. }    /* CWarningsDialog::SetupItems */
  211.  
  212. /******************************************************************************
  213.  ProviderChanged
  214. ******************************************************************************/
  215.  
  216. void CWarningsDialog::ProviderChanged( CCollaborator *aProvider, long reason,
  217.                                         void *info)
  218. {
  219.     Cell    selectedCell;
  220.     Boolean haveSelection;
  221.  
  222.     if ((aProvider == itsWarningsPane) && (reason == tableSelectionChanged))
  223.     {
  224.         SetupItems();
  225.     }
  226.     else
  227.         inherited::ProviderChanged( aProvider, reason, info);
  228.  
  229. }    /* CWarningsDialog::ProviderChanged */
  230.  
  231. /******************************************************************************
  232.  Dispose
  233. ******************************************************************************/
  234.  
  235. void CWarningsDialog::Dispose( void)
  236. {
  237.     inherited::Dispose();
  238. }
  239.  
  240.